﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace DAO
{
    class RunQuery
    {
        protected static string connString = @"Data Source=HADES-PC;AttachDbFilename=D:\QuanLiKhachSan.mdf;Integrated Security=True";

        public static bool RunNonQuery(string sql)
        {
            bool result = false;
            try
            {
                SqlConnection conn = null;
                conn = new SqlConnection(connString);
                conn.Open();
                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.ExecuteNonQuery();
                result = true;
                conn.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return result;
        }
        public static SqlDataAdapter RunQueryData(string sql)
        {
            try
            {
                SqlConnection conn = null;
                conn = new SqlConnection(connString);
                conn.Open();
                SqlDataAdapter a = new SqlDataAdapter(sql, conn);
                conn.Close();
                return a;
            }
            catch(Exception ex)
            {
                throw ex;
            }
        }
            
    }
}
